var http = require('../../../utils/http')
Page({
    /**
     * 页面的初始数据
     */
    data: {
        newFriendList: [],
        self: {},
        agreelist: {
            userAId: 0,
            userBId: 0
        },
        myFriendList: []

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            self: wx.getStorageSync('userInfo'),
            'agreelist.userBId': wx.getStorageSync('userInfo').id
        })
        this.findNewFriend();
        this.findmyFriend();
    },

    agree(e) {
        const that = this;
        http.post("/mini/agreeNewFriend",e.target.dataset.id,res=>{
            that.findNewFriend();
            that.findmyFriend();
        })
    },

    findNewFriend() {
        const id = this.data.self.id
        const that = this;
        http.get(`/mini/findNewFriend/${id}`,{},res=>{
            that.setData({
                newFriendList: res.data.data
            })
        })
    },

    findmyFriend() {
        const id = this.data.self.id
        const that = this;
        http.get(`/mini/findMyFriend/${id}`,{},res=>{
            that.setData({
                myFriendList: res.data.data
            })
        })
    },

    toaddcontacts() {
        wx.navigateTo({
            url: `/pages/message/contact/addcontact/addcontact`
        })
    },


})